package cn.zz.veggie.application.helper;

import cn.zz.comm.exception.classes.RecordEarlyUseException;
import cn.zz.comm.exception.classes.RecordNotFoundException;
import cn.zz.veggie.model.domain.Category;

/**
 * @author zhongq
 * @since 2024/4/28
 */
public class CategoryHelper {

    public static void requireNoNull(Category category, Integer id) {

    }

    public static void requireCanDelete(Category category) {

    }

    public static void requireNoUsed(Category childCategory, Integer id) {

    }

    public static void checkParentExist(Integer parentId, Category parentCategory) {
        if (Category.TOP_ID == parentId || parentCategory != null) {
            return;
        }
        throw new RecordNotFoundException("parent category not found" + parentId);
    }

    public static void requireNotExist(Integer id, Category category) {
        if (category != null && category.getId().equals(id)) {
            throw new RecordEarlyUseException("category early use " + category.getName());
        }

    }
}